package com.example.demo.controller.AuthorControl;

import com.example.demo.entity.BackResponseEntity;
import com.example.demo.entity.requestJson.AHomepageQueryReq;
import com.example.demo.entity.responseJson.AHomeFuzzyqueryAuthorRes;
import com.example.demo.entity.responseJson.BooknameFussyQUeryRes;
import com.example.demo.entity.responseJson.HomePageBInformatiomRres;
import com.example.demo.entity.responseJson.HomePageBMoreInfoRes;
import com.example.demo.service.AHomepageService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author : 杨丽辉
 * @date : 2021/3/6 11:02
 * @description:
 */
@RestController
@RequestMapping("/author/homepage")
@Api(value = "主页接口", tags = "主页接口")
public class AHomepageController {
    @Autowired
    private AHomepageService aHomepageService;

    @ApiOperation(value = "主页模糊查询作者名接口", notes = "这个结果出现在搜索框下面")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )

    @GetMapping("/fuzzyqueryaname")
    public BackResponseEntity<List<AHomeFuzzyqueryAuthorRes>> fuzzyQueryAname(AHomepageQueryReq aHomepageQueryReq) {
        return aHomepageService.fuzzyQueryAuthor(aHomepageQueryReq);
    }


    @ApiOperation(value = "主页模糊查询书名接口", notes = "这个结果出现在搜索框下面")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )

    @GetMapping("/fuzzyquerybookaname")
    public BackResponseEntity<List<BooknameFussyQUeryRes>> fuzzyQueryBookAname(AHomepageQueryReq aHomepageQueryReq) {
        return aHomepageService.fuzzyQueryBookname(aHomepageQueryReq);
    }

    @ApiOperation(value = "主页书名模糊查询接口", notes = "这里的condition是读者点击模糊查询出来的文章名，结果出现在主页")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )

    @GetMapping("/querybookname")
    public BackResponseEntity<List<HomePageBInformatiomRres>> queryBookname(AHomepageQueryReq aHomepageQueryReq) {
        return aHomepageService.queryHomepageBookname(aHomepageQueryReq);
    }

    @ApiOperation(value = "标签模糊查询接口", notes = "")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )

    @GetMapping("/querybooklabel")
    public BackResponseEntity<List<HomePageBMoreInfoRes>> queryLabels(AHomepageQueryReq aHomepageQueryReq) {
        return aHomepageService.queryLabels(aHomepageQueryReq);
    }
}
